let containerDiv = document.querySelector('.container');
let inputs = document.querySelectorAll('input');
let button = document.querySelector('#submit');

button.onclick = function() {
    let from = inputs[0].value;
    let to = inputs[1].value;
    let message = inputs[2].value;
    if(from == '' || to == '' || message == ''){
        return;
    }
    let rowDiv = document.createElement('div');
    rowDiv.className = 'row message';
    rowDiv.innerHTML = from + '对' + to + '说' + message;
    containerDiv.append(rowDiv);
    for(let input of inputs){
        input.value = '';
    }

    let revertButton = document.querySelector('#revert');
    revertButton.onclick = function(){
        let rows = document.querySelectorAll('.message');
        if(rows.length == 0){
            return;
        }
        containerDiv.removeChild(rows[rows.length-1]);
    }
}